package com.liuguang.gateway.config.filter;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CharacterEncodingFilter;

/**
 * @ClassName: ChracterEncodingFilter
 * @Description：
 * @Author: wanghr
 * Date: 2:19 PM 2020/9/15
 * Version: 1.0
 */
@Configuration
public class CharacterEncodingFilterConfig implements ApplicationContextAware {

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        CharacterEncodingFilter characterEncodingFilter = (CharacterEncodingFilter) applicationContext.getBean("characterEncodingFilter");
        characterEncodingFilter.setForceResponseEncoding(true);
    }
}
